package acm.第二轮;

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class E {
    public static List<int[]> list=new ArrayList<>();
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int n = sc.nextInt();

        fun(n,10,new int[10]);
        int size = list.size();
        System.out.println(size);
        for (int i = size-1; i >= 0; i--) {
            print(list.get(i));
        }
    }

    /**
     * @param rest:剩下的美味程度
     * @param index：还需要配几种
     */
    public static void fun(int rest,int index,int[] path){
        if (index==0&&rest==0){
            list.add(path.clone());
            return;
        }
        if (index<=0||rest<=0||rest<index){
            return;
        }
        for (int i=1;i<=3;i++){
            path[index-1]=i;
            fun(rest-i,index-1,path);
        }

//        path[index-1]=1;
//        fun(rest-1,index-1,path);
//        path[index-1]=2;
//        fun(rest-2,index-1,path);
//        path[index-1]=3;
//        fun(rest-3,index-1,path);
    }
    public static void print(int[] path){
        for (int i : path) {
            System.out.print(i+" ");
        }
        System.out.println();
    }
}
